import React from 'react'
import { createBrowserRouter } from 'react-router-dom'
import MainLayout from '../layouts/MainLayouts'
import ManagerLayouts from '../layouts/ManagerLayouts'
import QuestionLayout from '../layouts/QuestionLayout'
import Home from '../pages/Home'
import Login from '../pages/Login'
import Register from '../pages/Register'
import NotFound from '../pages/NotFound'
import List from '../pages/manager/list'
import Trash from '../pages/manager/trash'
import Stat from '../pages/question/stat'
import Star from '../pages/manager/star'
import Edit from '../pages/question/edit'

const router = createBrowserRouter([
    {
        path: '/',
        element: <MainLayout />,
        children: [
            {
                path: '/',
                element: <Home />
            },
            {
                path: 'login',
                element: <Login />
            },
            {
                path: 'register',
                element: <Register />
            },
            {
                path: 'manager',
                element: <ManagerLayouts />,
                children: [
                    {
                        path: 'list',
                        element: <List />
                    },
                    {
                        path: 'trash',
                        element: <Trash />
                    },
                    {
                        path: 'star',
                        element: <Star />
                    }
                ]
            },
            {
                path: '*',
                element: <NotFound />
            }
        ]
    },
    {
        path: 'question',
        element: <QuestionLayout />,
        children: [
            {
                path: 'stat/:id',
                element: <Stat />
            },
            {
                path: 'edit/:id',
                element: <Edit />
            }
        ]
    },
])
export default router

// ----- 常用路由变量 ------

export const LOGIN_PATHNAME = '/login'
export const HOME_PATHNAME = '/'
export const REGISTER_PATHNAME = '/register'
export const MANAGER_INDEX_PATHNAME = '/manager/list'